// miniprogram/pages/user/profile.js
Page({
  data: {
    userInfo: {},
    sceneType: '',
    sceneTypeName: '',
    totalPoints: 1250,
    rank: 2,
    totalUsers: 7,
    isAuditor: false,
    auditorLevel: 0
  },

  onLoad() {
    const app = getApp()
    const userInfo = app.globalData.userInfo
    this.setData({
      userInfo: userInfo,
      sceneType: app.globalData.sceneType,
      sceneTypeName: app.getSceneTypeName(app.globalData.sceneType),
      isAuditor: app.globalData.isAuditor,
      auditorLevel: app.globalData.auditorLevel
    })
  },

  goToAuditList() {
    wx.navigateTo({
      url: '/pages/audit/list'
    })
  },

  goToRedeemManage() {
    wx.navigateTo({
      url: '/pages/redeem/manage'
    })
  },

  goToRuleList() {
    wx.navigateTo({
      url: '/pages/rule/list'
    })
  },

  viewStatistics() {
    wx.switchTab({
      url: '/pages/statistics/index'
    })
  },

  contactSupport() {
    wx.showModal({
      title: '联系客服',
      content: '客服微信：points_support',
      showCancel: false
    })
  },

  aboutApp() {
    wx.showModal({
      title: '关于积分管理系统',
      content: '版本号：1.0.0\n简约大气的积分管理小程序，适用于情侣、家庭、公司等不同场景',
      showCancel: false
    })
  },

  logout() {
    wx.showModal({
      title: '确认退出',
      content: '确定要退出登录吗？',
      success: (res) => {
        if (res.confirm) {
          // 清除用户信息
          const app = getApp()
          app.globalData.userInfo = {}
          app.globalData.isAuditor = false
          app.globalData.auditorLevel = 0
          
          // 跳转到首页
          wx.switchTab({
            url: '/pages/index/index'
          })
        }
      }
    })
  }
})